package zuoye;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;

public class zy12 {
	/*作业2：在你生成的文件中，随机点名名字，在控制台打印一行
*/
	public static void main(String[] args) throws IOException {
		Scanner sc=new Scanner(System.in);
		System.out.println("请输入点名个数");
		int num=sc.nextInt();
		File file=new File(".//name.txt");
		ArrayList<String> name=read(file);
		for(int i=0;i<num;i++){
			int number = (int) (Math.random() * 99 + 0);
			System.out.println(name.get(number));
		}
	}
	private static ArrayList read(File file) throws IOException {
		ArrayList<String> names =new ArrayList<>();
		BufferedReader reader = new BufferedReader(new FileReader(file));
        String str="";
        while((str=reader.readLine())!=null){
        	//System.out.println(str.substring(0,3));
        	names.add(str.substring(0,3));
        }
        //System.out.println(map);
        reader.close();
        return names;
	}
}
